-
Couldn't load subscription status.
- Fork 13.9k
Add built-in const impls for Clone and Copy
#147866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
rustbot has assigned @petrochenkov. Use |
|
r? @lcnr for review or further reassignment |
|
|
||
| pub fn to_host_effect_clause(self, cx: I, constness: BoundConstness) -> I::Clause { | ||
| self.map_bound(|trait_ref| { | ||
| self.map_bound(|trait_ref: TraitRef<I>| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a misclick with rust-analyzer
|
|
||
| // only when `coroutine_clone` is enabled and the coroutine is movable | ||
| // impl Copy/Clone for Coroutine where T: Copy/Clone forall T in (upvars, witnesses) | ||
| ty::Coroutine(def_id, args) => match tcx.coroutine_movability(def_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check should_stall_coroutine? 🤔
rn checking const Clone for a coroutine should cause a query cycle
| } | ||
| } | ||
|
|
||
| fn evaluate_host_effect_for_copy_clone_goal<'tcx>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use SelectionContext::copy_clone_conditions instead of duplicating the match here?
We do the same in the new solver, so I'd expect either duplicating this match in both solvers or in none of them.
I guess the issue is that copy_clone_conditions only expects self types for which assembly succeeded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the built in Copy/Clone for non-const stuff is following the "assemble if looks okay, check nested predicates during confirmation", but the const stuff is not, so there is some divide here that prevents us from deduplicating without doing some refactor on how BuiltinCandidate works...
7d4ea10 to
042018d
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r+ rollup |
Rollup of 4 pull requests Successful merges: - #145939 (const `select_unpredictable`) - #147478 (More intuitive error when using self to instantiate tuple struct with private field) - #147866 (Add built-in `const` impls for `Clone` and `Copy`) - #148153 (Fix duplicate 'the the' typos in comments) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #147866 - fee1-dead-contrib:constclonebuiltin, r=lcnr Add built-in `const` impls for `Clone` and `Copy` cc `@compiler-errors`
cc @compiler-errors